#!/bin/bash

pid=$(ps -eo pid,%cpu,cmd --sort=%cpu |tail -1 |cut -d' ' -f1)

echo "

查看对应进程CPU的亲和性配置
"  >>/opt/monitor/pid_info.log."$(date +%F)"
taskset -p "$pid" >> /opt/monitor/pid_info.log."$(date +%F)"

echo "

看对应进程的堆栈信息
"  >>/opt/monitor/pid_info.log."$(date +%F)"
cat /proc/"$pid"/stack >>/opt/monitor/pid_info.log."$(date +%F)"

echo "

看对应进程的限制信息
"  >>/opt/monitor/pid_info.log."$(date +%F)"
cat /proc/"$pid"/limits >>/opt/monitor/pid_info.log."$(date +%F)"

echo "

看进程的状态信息
"  >>/opt/monitor/pid_info.log."$(date +%F)"
cat /proc/"$pid"/stat >>/opt/monitor/pid_info.log."$(date +%F)"


